function toggle(id){
	var value = document.getElementById(id).innerHTML;
	if(value == "0"){
		value = "1";
	}
	else{
		value = "0";
	}
	document.getElementById(id).innerHTML = value;
	updatePorts();
}

function updatePorts(){
	
	var i,j;
	var value, sum;
	var slot;
	
	for(i = 0; i<8; i++){
		sum  = 0;
		for(j = 0; j<8; j++){
			slot = "" + i + "" + j;
			value = document.getElementById(slot).innerHTML;
			if(value == "1"){
				value = 1;
			}
			else{
				value = 0;
			}
			sum += Math.pow(2,(7-j)) * value;
		}
		
		document.getElementById("gnd" + i).innerHTML = "" + sum.toString(16);
	}
	
}